package com.hdsx.restful.base;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.hdsx.restful.glzt.roadline.lxxx.bean.Line;
import com.hdsx.restful.glzt.roadline.lxxx.bean.LxdmMapLxmc;
import com.hdsx.restful.glzt.roadline.lxxx.bean.Znode;
import com.hdsx.restful.glzt.roadline.lxxx.service.LxService;
import com.hdsx.restful.glzt.roadline.nclx.service.INclxService;
import com.hdsx.restful.glzt.structure.crk.service.CrkServer;
import com.hdsx.restful.glzt.structure.fwq.service.FwqServer;
import com.hdsx.restful.glzt.structure.jkss.service.JkssService;
import com.hdsx.restful.glzt.structure.jtlgcz.service.JtlgczServer;
import com.hdsx.restful.glzt.structure.kbqbb.service.KbqbbServer;
import com.hdsx.restful.glzt.structure.ql.service.QlServer;
import com.hdsx.restful.glzt.structure.sd.service.SdServer;
import com.hdsx.restful.glzt.structure.sfz.service.SfzServer;
import com.hdsx.restful.glzt.structure.zcz.service.ZczServer;
/**
 * 
 * @author xiongxt
 *
 */
public class PreparedDataListener implements ServletContextListener {
	private static Map<String, List<Znode>> data = new HashMap<String, List<Znode>>();
	private static List<LxdmMapLxmc> lxmcs= new ArrayList<LxdmMapLxmc>();
	private static List<Line> thirdLines = new ArrayList<Line>();
	
	public static List<Znode> getData(String alias) {
		return data.get(alias);
	}
	
	public static void setData(Map<String, List<Znode>> data) {
		PreparedDataListener.data = data;
	}
	
	public static List<LxdmMapLxmc> getLxmcs() {
		return lxmcs;
	}

	public static void setLxmcs(List<LxdmMapLxmc> lxmcs) {
		PreparedDataListener.lxmcs = lxmcs;
	}
	
	public static List<Line> getThirdLines() {
		return thirdLines;
	}

	public static void setThirdLines(List<Line> thirdLines) {
		PreparedDataListener.thirdLines = thirdLines;
	}

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		LxService lxservice =  (LxService) ApplicationContextAwareImpl.getBean("lxServiceImpl");
		CrkServer crkServer =  (CrkServer) ApplicationContextAwareImpl.getBean("crkServerImpl");
		FwqServer fwqServer =  (FwqServer) ApplicationContextAwareImpl.getBean("fwqServerImpl");
		JkssService jkssService =  (JkssService) ApplicationContextAwareImpl.getBean("jkssServiceImpl");
//		JpjgServer jpjgServer =  (JpjgServer) ApplicationContextAwareImpl.getBean("jpjgServerImpl");
		JtlgczServer jtlgczServer =  (JtlgczServer) ApplicationContextAwareImpl.getBean("jtlgczServerImpl");
		KbqbbServer kbqbbServer =  (KbqbbServer) ApplicationContextAwareImpl.getBean("kbqbbServerImpl");
		QlServer qlservice =  (QlServer) ApplicationContextAwareImpl.getBean("qlServerImpl");
		SdServer sdServer =  (SdServer) ApplicationContextAwareImpl.getBean("sdServerImpl");
		SfzServer sfzServer =  (SfzServer) ApplicationContextAwareImpl.getBean("sfzServerImpl");
		ZczServer zczServer =  (ZczServer) ApplicationContextAwareImpl.getBean("zczServerImpl");
//		BzbpServer bzbpServer =  (BzbpServer) ApplicationContextAwareImpl.getBean("bzbpServerImpl");
		data.put("lx",lxservice.xzdjNode());
		data.put("crk",crkServer.crkNode());
		data.put("fwq",fwqServer.fwqNode());
		data.put("jkss",jkssService.jkssNode());
//		data.put("jpjg",jpjgServer.node());
		data.put("jtlg",jtlgczServer.JtlgNode());
		data.put("kbqb",kbqbbServer.kbqbbNode());
		data.put("ql",qlservice.qlNode());
		data.put("sd",sdServer.sdNode());
		data.put("sfz",sfzServer.sfzNode());
		data.put("zcz",zczServer.zczNode());
//		data.put("bzbp",bzbpServer.bzbpNode());
		
		 LxService lxService  = (LxService) ApplicationContextAwareImpl.getBean("lxServiceImpl");
	     INclxService nclxService = (INclxService) ApplicationContextAwareImpl.getBean("nclxServiceImpl");
	     lxmcs.addAll(lxService.selectResultsByParameter(null, null));
	     lxmcs.addAll(nclxService.selectResultsByParameter(null, null));
	     
	     thirdLines.addAll(lxService.third());
		
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub

	}

}
